import mysql from 'mysql2/promise';

const createPool = async()=>{
    const res =  await mysql.createConnection({
            user:'root',
            password:'f2456624568',
            database:'blog',
            connectTimeout: 1000,
            port:process.env.DATABASE_PORT,
      })
    return res 
}

let pool = await createPool()
pool.connect(async(err)=>{
      if(err && err.code === 'PROTOCOL_CONNECTION_LOST'){
         pool = await createPool()
      }
})



export default pool